<template>
  <div class="_wz_cent_main _wz_deptLearningUser">
    <Card dis-hover :bordered="true">
      <p slot="title">培训信息</p>
      <div class="_wz_ztList_cont_span">
        课程培训：<span>{{ !!parentSelectData.trainProgramName ? parentSelectData.trainProgramName : '--' }}</span>
        <Divider type="vertical" />
        培训时长：<span>{{ !!parentSelectData.trainProgramDeptTotalDuration ? parentSelectData.trainProgramDeptTotalDuration : 0 }} 分钟</span>
        <Divider type="vertical" />
        课题数量：<span>{{ !!parentSelectData.trainProgramDeptMaterialNumber ? parentSelectData.trainProgramDeptMaterialNumber : 0 }} 课件</span>
        <Divider type="vertical" />
        培训时间：<span>{{ !!parentSelectData.trainProgramDeptBeginDate ? parentSelectData.trainProgramDeptBeginDate : '--' }} - {{ !!parentSelectData.trainProgramDeptEndDate ? parentSelectData.trainProgramDeptEndDate : '--' }}</span>
        <Divider type="vertical" />
        报名人数：<span>{{ !!parentSelectData.trainProgramDeptSignUpNumber ? parentSelectData.trainProgramDeptSignUpNumber : 0 }}</span>
        <Divider type="vertical" />
        未完成人数：<span>{{ !!parentSelectData.trainProgramDeptUnfinishedNumber ? parentSelectData.trainProgramDeptUnfinishedNumber : 0 }}</span>
        <Divider type="vertical" />
        完成人数：<span>{{ !!parentSelectData.trainProgramDeptFinishedNumber ? parentSelectData.trainProgramDeptFinishedNumber : 0 }}</span>
        <Divider type="vertical" />
        运输企业：<span>{{ !!parentSelectData.deptName ? parentSelectData.deptName : '--' }}</span>

      </div>
    </Card>
    <Card dis-hover :bordered="true">
      <p slot="title">列表</p>
      <wzTbale ref="wzTbale" :tableData="tableData"></wzTbale>
    </Card>

    <Drawer title="学习详情" v-model="deptLearnDetailsType" width="1000" :draggable="true">
      <deptLearnDetails v-if="deptLearnDetailsType" :selectData="selectData"></deptLearnDetails>
    </Drawer>


    <Spin size="large" fix v-if="spinShow"></Spin>
  </div>
</template>
<script>

import wzTbale from "../../../components/table/table";
import deptLearnDetails from "./deptLearnDetails";
export default {
  props: ['parentSelectData'],//接收来自父组件的数据
  components: {
    wzTbale,//列表
    deptLearnDetails,//学习详情
  },
  data() {
    return {
      deptLearnDetailsType:false,//学习详情
      spinShow:false,//本页加载
      selectData:{},
      tableData: {
        url: this.apiUrl.trainTrainProgramDeptPersonTrainProgramDeptPersonPageList,//请求地址
        method: 'post',//请求方式
        where: {trainProgramDeptPersonUuid:this.parentSelectData.uuid},//搜索条件
        height: 'auto',//表格高度 auto
        page: true,//分页是否使用
        columns: [//表头数据
          {type: 'index', width: 80, align: 'center', title: '序号'},
          {title: '从业人员', key: 'trainProgramPersonName', minWidth: 120,},
          {title: '身份证号', key: 'trainProgramPersonIdentifyNum', minWidth: 160,},
          {title: '证书编号', key: 'trainProgramPersonCertificateNo', minWidth: 140,},
          {title: '证书类型', key: 'trainProgramPersonCertificateType', minWidth: 210,},
          {title: '应学时长', key: 'trainProgramPersonTotalDuration', minWidth: 100, render: (h, params) => {
              return h('span', params.row.trainProgramPersonTotalDuration +' 分钟');
            }
          },
          {title: '已学时长', key: 'trainProgramPersonLearnDuration', minWidth: 100, render: (h, params) => {
              return h('span', params.row.trainProgramPersonLearnDuration +' 分钟');
            }
          },
          {title: '未完成课题', key: 'trainProgramPersonUnfinishedNumber', minWidth: 100, render: (h, params) => {
              return h('span', params.row.trainProgramPersonUnfinishedNumber +' 课件');
            }
          },
          {title: '已完成课题', key: 'trainProgramPersonFinishedNumber', minWidth: 100, render: (h, params) => {
              return h('span', params.row.trainProgramPersonFinishedNumber +' 课件');
            }
          },
          {title: '完成状态',fixed: 'right',key: 'trainProgramPersonFinish', minWidth: 130, render: (h, params) => {
              return h('Tag', {props: {type: 'dot',color: (params.row.trainProgramPersonFinish == 0) ? "error" : "primary"}}, (params.row.trainProgramPersonFinish == 0) ? "未完成" : "已完成")
            }
          },
          {
            title: '操作', key: 'value', fixed: 'right', width: 80, render: (h, params) => {
              let operationButtons = [];
              //查看
              operationButtons.push(
                h('span', {
                  style: {"color": "#2d8cf0", "cursor": "pointer"},
                  on: {
                    click: () => {
                      this.selectData = params.row;
                      this.deptLearnDetailsType = true;
                    }
                  }
                }, '查看')
              );

              return operationButtons;
            }
          },
        ],
        format: {//返回数据格式
          list: ['data'],//数据list
          count: ['count'],//数据总量
        },
      },

    }
  },
  beforeCreate() {//beforeCreate创建前状态

  },
  created() {//created创建完毕状态
  },
  beforeMount() {//beforeMount挂载前状态   DOM 元素然后塞入页面的过程

  },
  mounted() {//mounted 挂载结束状态

  },
  methods: {//执行的方法

  },
  watch: {//监听

  },
  beforeUpdate() {//beforeUpdate 更新前状态

  },
  updated() {//updated 更新完成状态

  },
  beforeDestroy() {//beforeDestroy 销毁前状态

  },
  destroyed() {//destroyed 销毁完成状态

  }
}
</script>


<style lang="less">
._wz_deptLearningUser {
  height: 100%;
  display: flex;
  flex-direction: column;

  ._wz_ztList_cont_span {
    line-height: 30px;
    color: #ababab;

    span {
      margin: 0 10px 0 0;
      color: #01AAED;
      word-break: break-all;
    }
  }

}
</style>
